<template>
</template>

<script>
	import api from '../../api/index.js'
	export default {
		data() {
			return {
				orderId: '', //订单id
				advanceFlag: '', //是否是普通订单预售订单
				payStage: '', //是否完成订单
			}
		},
		onLoad() {

		},
		onShow() {
			this.getOrderid()
		},
		methods: {
			//获取订单id
			getOrderid() {
				var reg = new RegExp("(^|&)" + "orderId" + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
				var r = window.location.search.substr(1).match(reg); //匹配目标参数
				if (r != null) {
					this.orderId = unescape(r[2]);
					this.getAdvanceFlag()
				} else {
					this.orderId = null;
				}
			},
			// //获取advanceDlag
			getAdvanceFlag() {
				var reg = new RegExp("(^|&)" + "advanceFlag" + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
				var r = window.location.search.substr(1).match(reg); //匹配目标参数
				if (r != null) {
					this.advanceFlag = unescape(r[2]);
					this.getPaystage()
				} else {
					this.advanceFlag = null;
				}
			},
			// 获取支付结果
			getPaystage() {
				var reg = new RegExp("(^|&)" + "payStage" + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
				var r = window.location.search.substr(1).match(reg); //匹配目标参数
				if (r != null) {
					this.payStage = unescape(r[2]);
					if (this.advanceFlag == 0||this.payStage==1) {
						uni.redirectTo({
							url: '/pages/guarantee/guarantee?source=1&orderId=' + this.orderId
						});
					}else if(this.advanceFlag == 1&& this.payStage==0) {
						//payStage==0 付定金  payStage==1付尾款
						uni.redirectTo({
							url: `/pages/mineOrder/mineOrder?tabCurrentIndex=2`
						})
					}
				} else {
					this.payStage = null;
				}
			}

		}
	}
</script>

<style>
</style>
